package com.huonan.test.test2;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description
 * @Author huonan
 * @Date 2021/9/8 上午9:16
 * @Version V1.0
 **/
@Slf4j
public class test {

    public static void main(String[] args) throws IOException {
        String hcPath = "/Users/lxp/IdeaProjects/Study/MainTest/data/hc_video-user/2024-04-18-user_v2_douyin-1";
        String i7Path = "/Users/lxp/IdeaProjects/Study/MainTest/data/i7s_video-user/2024-04-18-user_v2_douyin-1";
        List<String> hclist = FileUtil.readUtf8Lines(hcPath);
        List<String> i7List = FileUtil.readUtf8Lines(i7Path);
        Set<String> i7UidSet = new HashSet<>();
        Set<String> hcUidSet = new HashSet<>();
        Set<String> i7NotHave = new HashSet<>();
        Set<String> i7Have = new HashSet<>();
        for (String l : hclist) {
            String uid = JSONUtil.parseObj(l).getStr("kw_uid");
            hcUidSet.add(uid);
        }

        for (String l : i7List) {
            String uid = JSONUtil.parseObj(l).getStr("kw_uid");
            if (!hcUidSet.contains(uid)) {
                i7NotHave.add(uid);
            } else {
                i7Have.add(uid);
            }
        }
        log.info("huichuan数据量:{}", hclist.size());
        log.info("i7s数据量:{}", i7List.size());
        log.info("重合数据量:{}", i7Have.size());
        log.info("不重合数据量:{}", i7NotHave.size());
        log.info("包含比例:{}", i7NotHave.size()/hclist.size());

    }

    public static String getIndexYear(String input) {
        String patternString = ".*_(\\d{4})(\\d{2}).*"; // 匹配任意字符，然后是一个下划线，然后是4个数字（年份），然后是2个数字（月份），然后再是任意字符
        Pattern pattern = Pattern.compile(patternString);
        Matcher matcher = pattern.matcher(input);

        if (matcher.find()) {
            String year = matcher.group(1); // 获取第一个括号内的匹配结果（年份）
            String month = matcher.group(2); // 获取第二个括号内的匹配结果（月份）
            // 如果需要，可以将整数转换回指定格式的字符串
            System.out.println("Year: " + year); // 输出：Year: 2023
            System.out.println("Month: " + month); // 输出：Month: 03
        }
        return null;

    }
}
